package com.tianqu.tms.www.transfer.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.transfer.viewhelper.CarOwnerAuditInputViewHelper;
import com.tianqu.tms.www.transfer.viewhelper.PublicSecurityAuditInputViewHelper;

public class CarOwnerAuditSearchInputAction extends TmsAction {

	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		
		CarOwnerAuditInputViewHelper view = new CarOwnerAuditInputViewHelper();
		
		if (null != uc.getAttribute("auditErr") && !"".equals(uc.getAttribute("auditErr"))) {
			String auditErr = (String)uc.getAttribute("auditErr");
			uc.removeAttribute("auditErr");
			
			view = (CarOwnerAuditInputViewHelper) uc.getAttribute(TmsConstants.VIEWHELP);
			if (view == null) {
				view = new CarOwnerAuditInputViewHelper();
			}
			
			// 【U0039】查询的结果不存在。
			if ("U0039".equals(auditErr)) {
				setErrorsToRequest(request, TmsConstants.U0039 ,null);
			}
			
			// 【U1405】出现重复流水号业务，请联系系统管理员。
			if ("U1405".equals(auditErr)) {
				setErrorsToRequest(request, TmsConstants.U1405 ,null);
			}
			
			// 如果有符合条件数据 并且 公安审核（transferRegister）为“2：公安未审核”或“3：公安审核未通过”，那么页面提示“【U1064】该业务未通过公安审核，不能进行车主审核。”
			if ("U1064".equals(auditErr)) {
				setErrorsToRequest(request, TmsConstants.U1068 ,null);
			}
		}

		request.setAttribute(VIEWHELP, view);
		
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
